<?php
class Category_model extends CI_Model{
	function get_valid_category(){
		$q = $this->db->get('valid_category');
		
		if($q->num_rows() > 0){
			foreach ($q->result() as $row){
				$data[] = $row;
			}
			return $data;
		}
	
	}
	
	function get_not_like_category($id){
		//$this->db->not_like($this->uri->segment(3));
		//$id = $this->uri->segment(3);
		$q = $this->db->query("SELECT * FROM valid_category WHERE category_id <> '2'");
		
		if($q->num_rows() > 0){
			foreach ($q->result() as $row){
				$data[] = $row;
			}
			return $data;
		}
	
	}
	function get_all_category(){
		$q = $this->db->get('all_category');
		
		if($q->num_rows() > 0){
			foreach ($q->result() as $row){
				$data[] = $row;
			}
			return $data;
		}
	
	}
	
	function create_category($data){
		if($this->db->insert('category',$data)){
			return true;
		}
	
	}
	
	function delete_category(){
		$this->db->where('category_id',$this->uri->segment(3));
		$this->db->delete('category');
	}
	
	function get_category(){
		$this->db->where('category_id',$this->uri->segment(3));
		$q = $this->db->get('valid_category');
		if($q->num_rows() > 0){
			foreach ($q->result() as $row){
				$data[] = $row;
			}
			return $data;
		}
	
	}
	
	function update_category($data){
		$this->db->where('category_id',$data['category_id']);
		
		if($this->db->update('category',$data) == true){
			return true;
		}
	}

}